package com.cheetah.mapper;

import com.cheetah.entity.UserNetwork;
import java.util.List;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;

public interface UserNetworkMapper {
    @Insert({
        "insert into user_network (user_id, network_id, ",
        "org_id, position, ",
        "weight)",
        "values (#{userId,jdbcType=VARCHAR}, #{networkId,jdbcType=VARCHAR}, ",
        "#{orgId,jdbcType=INTEGER}, #{position,jdbcType=VARCHAR}, ",
        "#{weight,jdbcType=INTEGER})"
    })
    int insert(UserNetwork record);

    @Select({
        "select",
        "user_id, network_id, org_id, position, weight",
        "from user_network"
    })
    @Results({
        @Result(column="user_id", property="userId", jdbcType=JdbcType.VARCHAR),
        @Result(column="network_id", property="networkId", jdbcType=JdbcType.VARCHAR),
        @Result(column="org_id", property="orgId", jdbcType=JdbcType.INTEGER),
        @Result(column="position", property="position", jdbcType=JdbcType.VARCHAR),
        @Result(column="weight", property="weight", jdbcType=JdbcType.INTEGER)
    })
    List<UserNetwork> selectAll();
}